package com.anysoft.manager;

import android.content.Context;

import com.anysoft.config.AppConstant;
import com.anysoft.model.AccountLoginEntity;

/**
 * Created by lty
 */

public class UserInfoManager {
    /**
     * 登录成功后返回的用户数据
     */
    public static AccountLoginEntity accountLoginBean;
    private static UserInfoManager manager;
    private Context mContext;
    
    public UserInfoManager(Context context) {
        mContext = context;
    }
    
    public static UserInfoManager getInstance(Context context) {
        if (manager == null) {
            manager = new UserInfoManager(context);
        }
        return manager;
    }
    
    
    public void saveUserInfo(AccountLoginEntity bean) {
        AppConstant.token = bean.getToken();
        if (bean != null) {
            accountLoginBean = bean;
        }
    }
    
    /**
     * 判断是否需要登录
     *
     * @return true---需要登录
     */
    public boolean needLogin() {
        return accountLoginBean == null;
    }
    
    public AccountLoginEntity getAccountLoginEntity() {
        return accountLoginBean;
    }
    
    public void signOut() {
        accountLoginBean = null;
        AppConstant.token = "";
    }
}
